export default {
    key:"history",
    add:function(p){
      var dic = wx.getStorageSync(this.key) || [];
      for(var i = dic.length - 1;i>=0;i--){
        var temp = dic[i];
        if (temp.bookId == p.bookId && temp.chapterId == p.chapterId){
            dic.splice(i,1);       
        }
      }
      dic.unshift(p);
    
      for (var i = dic.length - 1; i >= 20; i--){
        dic.splice(i, 1);
      }
      wx.setStorageSync(this.key, dic);
    },
    getList: function () {
      return wx.getStorageSync(this.key) || [];
    }
  }